package com.vote.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.vote.entity.Topic;
import com.vote.entity.Vote;
import com.vote.mapper.VoteMapper;
import com.vote.service.IVoteService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.vote.vo.VoVo;
import com.vote.vo.VoteVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author vote group
 * @since 2020-04-08
 */
@Service
public class VoteServiceImpl extends ServiceImpl<VoteMapper, Vote> implements IVoteService {

    @CacheEvict(value = "Topic", allEntries = true)
    @Override
    public void insertList(List<Vote> votes) {
        insertBatch(votes);
    }

    @CacheEvict(value = "Topic", allEntries = true)
    @Override
    public void deleteByTid(Integer tid) {
        Wrapper<Vote> wrapper = new EntityWrapper<>();
        wrapper.eq("tid", tid);
        this.baseMapper.delete(wrapper);
    }
}
